﻿@{
    Bundle("jquery_jqGrid");
}
           
<script type="text/javascript">
    jQuery(document).ready(function () {
        jQuery('@ID("#grid")').jqGrid({
            mtype: 'post',
            url: '@Url.Action(Loc.Act("Grid"))',
            postData: {
                searchTerm: '@Request.QueryParam("searchTerm")'
            },
            colNames:
            [
                '#',
                '@T(Res.Name("Item"))',
                '@T(Res.Name("AdjustmentMin"))',
                '@T(Res.Name("AdjustmentMax"))',
                '@T(Res.Name("ExhaustionThreshold"))',
                '@T(Res.Name("Reserve"))',
                '@T(Res.Name("Flags"))',
                '&#9998'
            ],
            colModel: 
            [
                { name: 'EntityID', align: 'center', width: 50, fixed: true, index: 'ID', title: false },
                { name: 'Item', index: 'SKU', title: false },
                { name: 'AdjustmentMin', align: 'center', width: 100, fixed: true, sortable: false, title: false },
                { name: 'AdjustmentMax', align: 'center', width: 100, fixed: true, sortable: false, title: false },
                { name: 'ExhaustionThreshold', align: 'center', width: 100, fixed: true, sortable: false, title: false },
                { name: 'Reserve', align: 'center', width: 100, fixed: true, index: 'Reserve', title: false },
                { name: 'Flags', align: 'center', width: 300, fixed: true, sortable: false, title: false },
                { name: 'Action', align: 'center', width: 100, fixed: true, sortable: false, title: false }
            ],
            gridComplete: function() {
                var ids = jQuery('@ID("#grid")').jqGrid('getDataIDs');
                for (var i = 0; i < ids.length; i++) {
                    var actDelete = '<a href="@Url.Action(Loc.Act("Delete"))?id=' + ids[i] + '">@T(Res.In("Common").Of("Act").Name("Delete"))</a>';
                    jQuery('@ID("#grid")').jqGrid('setRowData', ids[i], { Action: actDelete });
                }
            },
            sortname: 'ID',
            sortorder: 'asc',
            pager: '@ID("#grid_pager")'
        });
    });
</script>
<table class="grid" id="@ID("grid")"></table>
<div class="pager" id="@ID("grid_pager")"></div>
